﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;

namespace WindowsFormsApp_e3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FileStream file1 = new FileStream( textBox1.Text,FileMode.Open, FileAccess.Read);
            FileStream file2 = new FileStream(textBox2.Text, FileMode.Open, FileAccess.Read); 
            FileStream newfile = new FileStream(@"data/"+textBox3.Text, FileMode.Create, FileAccess.Write);
            StreamReader str1 = new StreamReader(file1, System.Text.Encoding.Default);
            StreamReader str2 = new StreamReader(file2, System.Text.Encoding.Default);
            StreamWriter newstr = new StreamWriter(newfile, System.Text.Encoding.Default);
            string st1 = str1.ReadLine();
            while (st1 != null)
            {
                newstr.WriteLine(st1);
                textBox4.AppendText(st1+"\r\n");
                textBox6.AppendText(st1 + "\r\n");
                st1 = str1.ReadLine();
            }
            str1.Close();
            
            string st2 = str2.ReadLine();
            while (st2 != null)
            {
                newstr.WriteLine(st2);
                textBox5.AppendText(st2 + "\r\n");
                textBox6.AppendText(st2 + "\r\n");
                st2 = str2.ReadLine();
            }
            str2.Close();
            newstr.Close();
        }
    }
}
